<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">排水量基础信息</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">测点编码：</text></view>
                  <input  placeholder="请输入测点编码" v-model="model.stationCode"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">煤矿编码：</text></view>
                  <input  placeholder="请输入煤矿编码" v-model="model.stationMine"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">排水点位置 ：</text></view>
                  <input  placeholder="请输入排水点位置 " v-model="model.equipmentPosition"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">覆盖范围(测点所属区域名称)：</text></view>
                  <input  placeholder="请输入覆盖范围(测点所属区域名称)" v-model="model.coverageArea"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">排水采集点坐标 X：</text></view>
                  <input type="number" placeholder="请输入排水采集点坐标 X" v-model="model.coordinateX"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">排水采集点坐标 Y：</text></view>
                  <input type="number" placeholder="请输入排水采集点坐标 Y" v-model="model.coordinateY"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">排水采集点坐标 Z：</text></view>
                  <input type="number" placeholder="请输入排水采集点坐标 Z" v-model="model.coordinateZ"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">泵房名称：</text></view>
                  <input  placeholder="请输入泵房名称" v-model="model.pumpHouse"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">水泵名称 ：</text></view>
                  <input  placeholder="请输入水泵名称 " v-model="model.pumpName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">水泵效率：</text></view>
                  <input type="number" placeholder="请输入水泵效率" v-model="model.pumpEfficiency"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">水泵额定流量：</text></view>
                  <input type="number" placeholder="请输入水泵额定流量" v-model="model.ratedFlow"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">水泵型号：</text></view>
                  <input  placeholder="请输入水泵型号" v-model="model.pumpType"/>
                </view>
              </view>
              <my-date label="数据定义时间：" v-model="model.installationDate" placeholder="请输入数据定义时间"></my-date>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">开关泵标识 ：</text></view>
                  <input type="number" placeholder="请输入开关泵标识 " v-model="model.switchPump"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">排水量：</text></view>
                  <input type="number" placeholder="请输入排水量" v-model="model.displacement"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">测点名称：</text></view>
                  <input  placeholder="请输入测点名称" v-model="model.drillName"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "PslcddyForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/hydrology/pslcddy/queryById",
                  add: "/hydrology/pslcddy/add",
                  edit: "/hydrology/pslcddy/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
